package view.contents;

import java.awt.Dimension;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class RecordContainer extends JPanel {
	public RecordContainer(ImageBox imgBox, TextLabelBox address, TextLabelBox city, TextLabelBox price, int width, int height) {
		super();
		// this.setBackground(Color.red);
		//this.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
		// this.setBorder(BorderFactory.createLineBorder(Color.blue, 10));
		this.setSize(new Dimension(width, height));
		this.setPreferredSize(new Dimension(width, height));
		this.setMaximumSize(new Dimension(width, height));
		BoxLayout bl = new BoxLayout(this, BoxLayout.Y_AXIS);
		this.setLayout(bl);

		if (address != null) {
			this.add(address);
		} else {
			this.add(new JLabel("NO ADDRESS"));
		}
		// if(city!=null) this.add(city);
		JPanel imagePanel = new JPanel();
		imagePanel.setOpaque(false);
		imagePanel.setPreferredSize(new Dimension(width, height-20));
		if (imgBox != null) {
			imagePanel.add(imgBox);
		}
		this.add(imagePanel);
		if (price != null) {
			this.add(price);
		} else {
			this.add(new JLabel("NO PRICE"));
		}
		this.setOpaque(false);
	}

	public static void main(String[] args) {
		JFrame testFrame = new JFrame("testFrame");
		testFrame.add(new RecordContainer(null, null, null, null, 800, 600));
		testFrame.pack();
		testFrame.setVisible(true);
	}
}